<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="pragram" content="no-cache"/>
    <meta http-equiv="cache-control" content="no-cache, must-revalidate"/>
    <meta http-equiv="expires" content="0"/>
    <meta name="renderer" content="webkit"/>
  <%--  <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>--%>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes" />

    <title>登录</title>
    <link rel="stylesheet" href="/assets/css/common.css">
    <link rel="stylesheet" href="/assets/css/login.css">

</head>
<body>
<div id="cms">
    <div class="login-box">
        <div class="logo clearfix">
            <img src="/assets/images/logo-red.png" alt="logo">
            <div>后台管理系统</div>
        </div>
        <div class="login">
            <form id="loginForm" method="post" onsubmit="return false;">
                <div class="login-title">用户登录</div>
                <div class="input-box ">
                    <div class="input-left">账号</div>
                    <input id="username" name="username" type="text" class="account-input"   placeholder="请输入账号">
                </div>
                <div class="input-box">
                    <div class="input-left">密码</div>
                    <input id="loginPwd" name="password" type="password" class="password-input"   placeholder="请输入密码">
                </div>
                <button class="login-btn" id="login_btn" onclick="submitLoginForm()">登录</button>
            </form>
        </div>

    </div>
</div>

</body>
<script type="text/javascript" src="/assets/js/lib/jquery-1.12.3.js"></script>
<script type="text/javascript" src="/assets/js/common.js"></script>
<%--<script type="text/javascript" src="/assets/js/login.js"></script>--%>

<script>
    //<![CDATA[
    //表单提交
    function submitLoginForm() {
//        $('#addLoginInfo').empty();
        var username = $('#username').val().trim();
        var password = $("#loginPwd").val().trim();
//        if (password != null && password != "") {
//            password = ($("#loginPwd").val()).trim(); //去空,不加密
//        }
        $.ajax({
            url: "/submitLoginParam",
            type: "POST",
            dataType:'json',
            data: {"username": username, "password": password},
            success: function (data) {


                if (data.code == 1) {
//                    $('#addLoginInfo').empty();
//                    $('#addLoginInfo').append("<br/><div style= 'width: 304px;height:36px; border-radius: 5px;" +
//                        "background-color: #7db72f;opacity:0.9; font-size: 18px;font-weight: 500; text-align: center'>" +
//                        "<strong style='line-height: 36px'>登录成功</strong></div>");
                    var originUrl = data.data;
//                    window.setTimeout(function () {
//                        jumpToOriginUrl(originUrl);
//                    }, 1000);
                    window.location.href=originUrl;
                } else if(data.code ==10 ){
//                    $('#addLoginInfo').empty();
//                    $('#addLoginInfo').append("<br/><div style= 'width: 304px;height:36px; border-radius: 5px;" +
//                        "background-color: orangered;opacity:0.9; font-size: 18px;font-weight: 500; text-align: center'>" +
//                        "<strong style='line-height: 36px'>" + data.msg + "</strong></div>");
//                    setTimeout($('#addLoginInfo').empty(), 3000);
                    alert(data.msg);

                } else{



                    alert("未知错误");

                }
            },
//            error:function (err) {
//                console.log(err)
//            },
//            complete:function () {
//                console.log(11);
//            }
        });
    }

    $("body").keydown(function () {
        if (event.keyCode == "13") {//keyCode=13是回车键
            $('#login_btn').click();
        }
    });
    /**
     * 跳转到原始访问页面
     * @param originUrl
     */
    function jumpToOriginUrl(originUrl) {
        window.location.href = originUrl;
    }
    //]]>
</script>
</html>